<template>
	<view class="good-list">
		<view class="good-li" v-for="item in list" :key="item.id" @click="btn(item.id)">
			<!-- <image class="good-img" mode="widthFix" :src="item.goodImg"></image> -->
			<!-- <view class="item">
				<view class="title">{{item.goodName}}</view>
				<view class="div">
					<view class="price">{{item.goodPrice}} 元</view>
					<view class="sold">已售{{item.goodSold}}件</view>
				</view>
			</view> -->
			<view class="title">{{item.goodName}}</view>
			<image class="good-img" mode="widthFix" :src="item.goodImg"></image>
			<view class="price">{{item.goodPrice}} 元</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"good-list",
		// 设置子子组件接受父组件的选项
		props:{
			list : {
				type : Array,
				default(){
					return []
				}
			}
		},
		methods:{
			btn(id){
				uni.navigateTo({
					url:'/page_detail/detail/detail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
/* less和sass选择器可以父子嵌套 */
.good-list{
	background-color: #fff;
	display: flex;
	flex-wrap: wrap;
	margin: 0 -1%;
	
	.good-li{
		
		border-radius: 5px;
		margin: 0 2.5%;
		margin-top: 10px;
		width: 45%;
		text-align: center;
		background-image: linear-gradient(to bottom right,#f0ddff,#ffa0cb);
		
		
		.good-img{
			margin: 15px auto;
			width: 50%;
			border: 1px solid gainsboro;
		
		}
		// .item{
		// 	flex: 1;
		// 	display: flex;
		// 	align-content: space-around;
		// 	flex-wrap: wrap;
		// 	margin-left: 10px;
			.title{
				width: 9em;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				margin-top: 10px;
				
				// font-size: 16px;
				// line-height: 40px;
				// height: 80px;
				// margin-bottom: 20px;
				// overflow: hidden;
			}
			// .div{
			// 	display: flex;
			// 	width: 100%;
			// 	justify-content: flex-start;
			// 	align-items: center;
				.price{
					font-size: 16px;
					color: red;
					margin-bottom: 10px;
				}
				// .sold{
				// 	font-size: 14px;
				// 	margin-left: 16px;
				// 	color: gray;
				// }
			//}
		//}
	}
}
</style>